package BLC

import (
	"../wallet"
	"bytes"
)

//交易输出
type TXOutput struct {
	Value int //分
	Ripemd160Hash []byte //hash160
}

func (tx *TXOutput)Lock(address string){
	publickeyHash:=wallet.Base58Decode([]byte(address))
	tx.Ripemd160Hash=publickeyHash[1:len(publickeyHash)-4]
}

func NewTXOutput(amount int,address string)*TXOutput{
	txOutput:=&TXOutput{amount,nil}
	txOutput.Lock(address)
	return txOutput
}

//是否能够解锁账号
func (out *TXOutput)UnlockedTXOutput(address string)bool{
	publickeyHash:=wallet.Base58Decode([]byte(address))
	return bytes.Compare(out.Ripemd160Hash,publickeyHash[1:len(publickeyHash)-4])==0
}